package Gerrit::Link;
use 5.018;
use warnings;
use DTask::Link;

sub _parseCLCommitMessage
{
	my ($message) = @_;
	my $info = {};
	$info->{tower_todo} = [ $message =~ m!https://tower\.im/projects/[0-9a-f]{32}/todos/([0-9a-f]{32})!g  ];

	my $bugilla_show_bug = quotemeta "https://bugzilla.deepin.io/show_bug.cgi?id=";
	$info->{bugzilla} = [ $message =~ m{$bugilla_show_bug(\d+)}g ];
	return $info;
}

sub createLinkByCLCommitMessage
{
	my ($cl_num, $message, $cb) = @_;
	my $info = _parseCLCommitMessage($message);

	DTask::Link::allLink('gerrit', $cl_num, $info, sub {
		warn "createLinkByCLCommitMessage : done";
		$cb->();
	});
}




1;
